package config

import (
	"os"
)

type Config struct {
	GRPCPort          string
	MongoURI          string
	MongoDB           string
	TicketServiceAddr string
}

func Load() *Config {
	return &Config{
		GRPCPort:          getEnv("GRPC_PORT", "50056"),
		MongoURI:          getEnv("MONGO_URI", "mongodb://mongodb:27017"),
		MongoDB:           getEnv("MONGO_DB", "devops_smartbot"),
		TicketServiceAddr: getEnv("TICKET_SERVICE_ADDR", "ticket-service:50052"),
	}
}

func getEnv(key, defaultValue string) string {
	if value := os.Getenv(key); value != "" {
		return value
	}
	return defaultValue
}
